package experiment5.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ScreenInput extends Thread {
    ScreenSayIntf screenSayIntf;

    public ScreenInput(ScreenSayIntf screenSayIntf) {
        this.screenSayIntf = screenSayIntf;
    }

    public void run() {
        while (true) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = null;
            try {
                str = br.readLine();
                if (str != null && !str.trim().equals("")) {
                    screenSayIntf.say(str);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
